﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Licensed MIT: http://www.opensource.org/licenses/mit-license.php

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DNA.OpenAPI.Sitemap;
using DNA.Utility;

namespace DNA.Mvc.Services
{
    public class SiteMapIndexGenerator : CommandContainer
    {
        public SiteMapIndexGenerator(IEnumerable<SiteMapGeneratorBase> sitemaps) { this.InnerItems.AddRange(sitemaps); }

        //public SiteMapIndexGenerator(string manifest) { }

        public SitemapIndex GetSitemapIndex()
        {
            var sitemapIndex = new SitemapIndex()
            {
                SiteMapFiles = new List<Sitemap>()
            };
            Invoke(new CommandContext() { Bag = sitemapIndex });
            return sitemapIndex;
        }

        public string GetXml()
        {
            return XmlSerializerUtility.SerializeToXml(this.GetSitemapIndex());
        }
    }
}
